<template>
  <div>
    <h2>{{uname}}</h2>
    <h2>{{roleName}}</h2>
    <el-table
        :data="tableData"
        border
        style="width: 100%">
      <el-table-column

          prop="taskName"
          label="任务名字"
          width="150">
      </el-table-column>
      <el-table-column
          prop="taskId"
          label="任务id"
          width="120">
      </el-table-column>
      <el-table-column
          prop="processInstanceId"
          label="实例"
          width="120">
      </el-table-column>
      <el-table-column
          prop="assignee"
          label="名称"
          width="120">
      </el-table-column>
      <el-table-column
          prop="id"
          label="主键id"
          width="120">
      </el-table-column>
      <el-table-column
          prop="reason"
          label="原因"
          width="120">
      </el-table-column>
      <el-table-column
          prop="days"
          label="天数"
          width="120">
      </el-table-column>


      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button  v-if="roleName=='员工'" @click="tijiao(scope.row)" type="text" size="small">提交申请</el-button>
          <el-button  v-if="roleName=='部门主管'" @click="bumen(scope.row)" type="text" size="small">通过</el-button>

          <el-button  v-if="roleName=='经理'" @click="jingli(scope.row)" type="text" size="small">通过</el-button>
          <el-button  v-if="roleName=='人事'" @click="renshi(scope.row)" type="text" size="small">通过</el-button>
          <el-button  v-if="roleName=='人事'" @click="bohui(scope.row)" type="text" size="small">驳回</el-button>

        </template>
      </el-table-column>




    </el-table>
  </div>
</template>

<script>
export default {
  name: "TlistView",
  data() {
    return {
      tableData:[],
      uname:sessionStorage.getItem("uname"),
      roleName:sessionStorage.getItem("roleName")
    }
  }, methods: {
    tijiao(row){
      this.axios.post("complete",{
        taskId:row.taskId,
        taskname:row.taskName,

      }).then(res=>{
        console.log(res)
       this.list();


      })
    },
    bumen(row){
      this.axios.post("complete",{
        taskId:row.taskId,
        taskName:row.taskName,
        days:row.days,

      }).then(res=>{
        console.log(res)
        this.list();


      })
    },
    renshi(row){
      this.axios.post("complete",{
        taskId:row.taskId,
        taskName:row.taskName,
        id:row.id,

        "flag":"1"

      }).then(res=>{
        console.log(res)
        this.list();


      })
    },
    bohui(row){
      this.axios.post("complete",{
        taskId:row.taskId,
        taskname:row.taskName,

        "flag":"0"
      }).then(res=>{
        console.log(res)
        this.list();


      })
    },
    jingli(row){
      this.axios.post("complete",{
        taskId:row.taskId,
        taskname:row.taskname,
        "flag":"1"
      }).then(res=>{
        console.log(res)
        this.list();


      })
    },

    list(){
      this.axios.post("tlist").then(res=>{

          this.tableData=res.data;


      })
    },
  }, created() {
    this.list();
  }
}
</script>

<style scoped>

</style>